using Fluent.IO;
using TripleA.Core.Interfaces.Entities;

namespace TripleA.Core.Extensions.FileSystem
{
    /// <summary>
    /// This step will clean/clear the contents of the folder specified
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class CleanFolderStep<T> : StepBase<T>
        where T: Context
    {
        private readonly string _folder;

        public CleanFolderStep(string folder)
        {
            _folder = folder;
        }

        public override void Execute(T context)
        {
            var path = Path.Get(_folder);
            path.Delete(true);
            Path.CreateDirectory(path.FullPath);
        }
    }
}